package com.feicheng.controller.shop.admin.client;


import com.alibaba.fastjson.JSONObject;
import com.feicheng.common.constant.Constant;
import com.feicheng.common.result.ResultInfo;
import com.feicheng.service.IFClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cailongyang
 * @since 2021-12-02
 */
@RestController("/shop/admin/client")
@RequestMapping("/shop/admin/client")
public class ClientController {
    @Autowired
    private IFClientService ifClientService;
    @GetMapping("/page")
    public ResultInfo getClientPage(String clientId,
                                    String clientName,
                                    String phone,
                                    String sex,
                                    String age,
                                    String maxAge,
                                    String minAge,
                                    String name,
                                    String depositAmount,
                                    String vipTimeLongs,
                                    String dFlag,
                                    String vipStatu,
                                    Integer storeId,
                                    @RequestParam(defaultValue = "1") Integer current,
                                    @RequestParam(defaultValue = "10") Integer size){


        JSONObject result = new JSONObject();
        result.put(Constant.ENTITY.CLIENT.CLIENT_ID, clientId);
        result.put(Constant.ENTITY.CLIENT.CLIENT_NAME, clientName);
        result.put(Constant.ENTITY.CLIENT.PHONE, phone);
        result.put(Constant.ENTITY.CLIENT.SEX, sex);
        result.put(Constant.ENTITY.CLIENT.AGE, age);
        result.put(Constant.HTTP.PARAM.MAXAGE,maxAge);
        result.put(Constant.HTTP.PARAM.MINAGE,minAge);
        result.put(Constant.ENTITY.STORE.NAME, name);
        result.put(Constant.ENTITY.DEPOSIT_RECORD.AMOUNT, depositAmount);
        result.put(Constant.ENTITY.ACCOUNT.TIME_LONGS, vipTimeLongs);
        result.put(Constant.ENTITY.CLIENT.D_FLG,dFlag);
        result.put(Constant.ENTITY.VIP.STATU, vipStatu);
        result.put(Constant.ENTITY.STORE.STORE_ID,storeId);
        result.put(Constant.HTTP.PARAM.CURRENT, current);
        result.put(Constant.HTTP.PARAM.SIZE, size);
        ifClientService.getClientsByPage(result);
        return ifClientService.getClientsByPage(result);

    }
    @GetMapping("/info")
    public ResultInfo selectById(Integer clientId){
        return ifClientService.getClient(clientId);
    }
}
